package com.perfma.xtest.tool;

import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

import java.util.List;
import java.util.Set;

/**
 * @author: junhui.si
 * @date: 2021-10-12 18:31
 **/
public class UniqueName {
    public static void main(String[] args) {
//        List<String> nameList = Lists.newArrayList();
//        nameList.add("哈哈");
//        nameList.add("哈哈");
//        nameList.add("哈哈");
//        nameList.add("哈哈");
//        nameList.add("哈哈");
//        nameList.add("哈哈");
//        nameList.add("哈哈");
//
//        Set<String> newNameSetxxx = Sets.newHashSet(nameList);
//        List<String> newNameSet = Lists.newArrayList();
//        for (String name : nameList) {
//            if (newNameSet.contains(name)) {
//                String newName = getUniqueName(Sets.newHashSet(newNameSetxxx), name, 0);
//                newNameSet.add(newName);
//                newNameSetxxx.add(newName);
//            } else {
//                newNameSet.add(name);
//            }
//        }
//        System.out.println(newNameSet);


//        String newDescription = "\n\n123";
//        if (!Strings.isNullOrEmpty(newDescription)){
//            newDescription.substring(3, newDescription.length());
//        }
//        System.out.println(newDescription);
//        String s = "<p>12</p><p>阿萨德</p><p><img src=\"\" style=\"max-width:100%;\"><br></p><p>为单位无</p><p><img src=\"https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png\" style=\"max-width:100%;\"><br></p>";
//        s = s.replaceAll("<img[^>]*>", "");
//        s = s.replace("<br>", "\n");
//        s = s.replaceAll("<[.[^<]]*>", "");
//        System.out.println(s);
//        System.out.println(1.00d ==1);
//        System.out.println(1d ==1);
//        System.out.println(1.0d ==1);
//        System.out.println(1.00d ==1d);
        List<String> list = Lists.newArrayList("1", "2", "-100%");
        list.forEach(s->{
            if ("-100%".equals(s)) {
                s="-";
            }
        });
        System.out.println(list);
    }


    private static String getUniqueName(Set<String> nameSet, String name, int i) {
        if (nameSet.contains(name + "_" + i)) {
            return getUniqueName(nameSet, name, i + 1);
        }
        return name + "_" + i;
    }
}
